package com.dean.ui.utils;

import java.awt.*;

/**
 * @author dean
 * @version 1.0
 * @description: 屏幕工具
 * @date 2024/8/7 9:27
 */
public class ScreenUtils {
    private static final Toolkit toolkit = Toolkit.getDefaultToolkit();
    private static final GraphicsDevice device =
            GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    public static int monitorWidth(){
        return toolkit.getScreenSize().width;
    }

    public static int monitorHeight(){
        return toolkit.getScreenSize().height;
    }

    public static int resolutionWidth(){
        return device.getDisplayMode().getWidth();
    }

    public static int resolutionHeight(){
        return device.getDisplayMode().getHeight();
    }

    public static double scaleX(){
        return device.getDefaultConfiguration().getDefaultTransform().getScaleX();
    }

    public static double scaleY(){
        return device.getDefaultConfiguration().getDefaultTransform().getScaleY();
    }

    public static void showScreenInfo(){
        System.out.println("显示器尺寸如下:");
        System.out.println(monitorWidth());
        System.out.println(monitorHeight());
        System.out.println("显示器分辨率如下:");
        System.out.println(resolutionWidth());
        System.out.println(resolutionHeight());
        System.out.println("显示器缩放比例如下:");
        System.out.println(scaleX());
        System.out.println(scaleY());
    }

    public static void main(String[] args) {
        showScreenInfo();
    }
}
